package org.aeon.fasttasks.core.config;

import org.aeon.fasttasks.core.manager.TaskManager;
import org.aeon.fasttasks.core.properties.TaskProperties;
import org.aeon.fasttasks.core.recorder.TaskRecorder;
import org.aeon.fasttasks.core.scanner.AnnotationScanner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @Date 2024/9/18 0018 9:42
 * @Author aeon
 * @Description 自动配置类
 */
@Import({ThreadPoolConfig.class, AnnotationScanner.class})
@Configuration
@EnableConfigurationProperties(TaskProperties.class)
public class BatchWorkTasksAutoConfig {

    @Bean
    @ConditionalOnMissingBean
    public TaskRecorder taskProperties(TaskProperties taskProperties) {
        return taskProperties.enableTaskRecords() ? new TaskRecorder() : null;
    }

    @Bean
    @ConditionalOnMissingBean
    public TaskManager taskManager() {
        return new TaskManager();
    }

}
